import Vue from 'vue'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import api from './api' // 导入api接口
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/vant.js'
import setCookie from '@/commonFun/index'
import getCookie from '@/commonFun/getcook'
import delCookie from '@/commonFun/delcook'
const base_serve = "http://home.tangmu.xin/"
import Storage from 'vue-web-storage';  //缓存依赖
Vue.use(Storage); 
Vue.use(VueQuillEditor, {
	placeholder: '请输入内容'
});



Vue.prototype.$setcookie = setCookie
Vue.prototype.$getcookie = getCookie
Vue.prototype.$delcookie = delCookie
Vue.config.productionTip = false

Vue.prototype.$api = api // 将api挂载到vue的原型上
Vue.prototype.$base_serve = base_serve


/**
 * 系统随机参数
 * @param {type} len
 * @returns {String}
 */
Vue.prototype.randomString = function(len) {
	len = len || 32;
	let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
	let maxPos = $chars.length;
	let pwd = '';
	for (var i = 0; i < len; i++) {
		pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
	}
	return pwd;
}


Vue.prototype.tologin = function(path) {

	// if (this.getCookie("token") == null || this.getCookie("token") == '') {
	router.push({
		path: '/login',
		query: {
			redirect: router.currentRoute.fullPath
		}
	});

}

Vue.prototype.loginOut = function() {

	Vue.prototype.$dialog.confirm({
		title: '提示',
		message: '确定退出登录？'
	}).then(() => {
		// on confirm
		Vue.prototype.$delcookie("userInfo")
		Vue.prototype.$delcookie("jy_token")
		Vue.prototype.tologin()
	}).catch(() => {
		// on cancel
	});


}
new Vue({
	router,
	store,
	render: h => h(App)
}).$mount('#app')
